package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BdDefdoclist;
import com.ruoyi.system.service.IBdDefdoclistService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自定义档案列Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@Controller
@RequestMapping("/system/defdoclist")
public class BdDefdoclistController extends BaseController
{
    private String prefix = "system/defdoclist";

    @Autowired
    private IBdDefdoclistService bdDefdoclistService;

    @RequiresPermissions("system:defdoclist:view")
    @GetMapping()
    public String defdoclist()
    {
        return prefix + "/defdoclist";
    }

    /**
     * 查询自定义档案列列表
     */
    @RequiresPermissions("system:defdoclist:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BdDefdoclist bdDefdoclist)
    {
        startPage();
        List<BdDefdoclist> list = bdDefdoclistService.selectBdDefdoclistList(bdDefdoclist);
        return getDataTable(list);
    }

    /**
     * 导出自定义档案列列表
     */
    @RequiresPermissions("system:defdoclist:export")
    @Log(title = "自定义档案列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BdDefdoclist bdDefdoclist)
    {
        List<BdDefdoclist> list = bdDefdoclistService.selectBdDefdoclistList(bdDefdoclist);
        ExcelUtil<BdDefdoclist> util = new ExcelUtil<BdDefdoclist>(BdDefdoclist.class);
        return util.exportExcel(list, "自定义档案列数据");
    }

    /**
     * 新增自定义档案列
     */
    @RequiresPermissions("system:defdoclist:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存自定义档案列
     */
    @RequiresPermissions("system:defdoclist:add")
    @Log(title = "自定义档案列", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BdDefdoclist bdDefdoclist)
    {
        return toAjax(bdDefdoclistService.insertBdDefdoclist(bdDefdoclist));
    }

    /**
     * 修改自定义档案列
     */
    @RequiresPermissions("system:defdoclist:edit")
    @GetMapping("/edit/{pkDefdoclist}")
    public String edit(@PathVariable("pkDefdoclist") String pkDefdoclist, ModelMap mmap)
    {
        BdDefdoclist bdDefdoclist = bdDefdoclistService.selectBdDefdoclistByPkDefdoclist(pkDefdoclist);
        mmap.put("bdDefdoclist", bdDefdoclist);
        return prefix + "/edit";
    }

    /**
     * 修改保存自定义档案列
     */
    @RequiresPermissions("system:defdoclist:edit")
    @Log(title = "自定义档案列", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BdDefdoclist bdDefdoclist)
    {
        return toAjax(bdDefdoclistService.updateBdDefdoclist(bdDefdoclist));
    }

    /**
     * 删除自定义档案列
     */
    @RequiresPermissions("system:defdoclist:remove")
    @Log(title = "自定义档案列", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bdDefdoclistService.deleteBdDefdoclistByPkDefdoclists(ids));
    }
}
